import {ActivatedRoute} from "@angular/router";
import {Product} from "../../service/entity/product";
import {ProductService} from "../../service/product/product.service";
import {Component, OnInit} from "@angular/core";
import {Comment} from "../../service/entity/comment";

@Component({
  selector: 'app-product-detail',
  templateUrl: './product-detail.component.html',
  styleUrls: ['./product-detail.component.css']
})
export class ProductDetailComponent implements OnInit {

  productTitle: string;

  product: Product;

  comments: Comment[];

  constructor(private routeInfo: ActivatedRoute, private productService: ProductService) {
  }

  ngOnInit() {
    let productId: number = this.routeInfo.snapshot.params['prductId'];
    this.productService.getProduct(productId).subscribe(
      data => this.product = data
    );
    this.productService.getCommentForProductId(productId).subscribe(
      comments => this.comments = comments
    );
    /*this.productTitle = this.routeInfo.snapshot.params['title'];*/
  }

}
